﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using GnProjectAssist;
using GnProjectAssist.Creator;
using Microsoft.VisualStudio.VCProjectEngine;

namespace GnProjectAssistWindow
{
	/// <summary>
	/// CreateClassWindow.xaml에 대한 상호 작용 논리
	/// </summary>
	public partial class CreateClassWindow : Window, IGnPerformCommand
	{
		public CreateClassWindow()
		{
			InitializeComponent();
		}

		public void Perform()
		{
			Nullable<bool> dialogResult = ShowDialog();
			if( dialogResult.HasValue && dialogResult.Value )
			{
				
			}
		}

		protected bool Create( Object createValue )
		{
            //try
            //{
            //    base.Create( createValue );

            //    VCProject vcProject = GnVCProject.GetSelectProject( GnAssist.Application );
            //    String classDataPath = AddintDataPath + "Class\\";
            //    String itemFullPath = null;
            //    String tempFile = null;

            //    List<String> itemList = new List<String>( 3 );
            //    if( createData.isInline )
            //    {
            //        itemFullPath = addfilePath + createData.inlineName;
            //        tempFile = classDataPath + "inline.inl";
            //        if( File.Exists( tempFile ) )
            //        {
            //            File.Copy( tempFile, itemFullPath );
            //            itemList.Add( itemFullPath );
            //        }
            //    }

            //    if( createData.isMakeCpp )
            //    {
            //        itemFullPath = addfilePath + createData.cppName;
            //        tempFile = classDataPath + "cpp.cpp";
            //        if( File.Exists( tempFile ) )
            //        {
            //            File.Copy( classDataPath + "cpp.cpp", itemFullPath );
            //            itemList.Add( itemFullPath );
            //        }
            //    }

            //    itemFullPath = addfilePath + createData.headerName;
            //    tempFile = classDataPath + "header.h";
            //    if( File.Exists( tempFile ) )
            //    {
            //        File.Copy( classDataPath + "header.h", itemFullPath );
            //        itemList.Add( itemFullPath );
            //    }

            //    iClassDocument changeFile = new iClassDocument();
            //    String fileName = iSystem.iFileAssist.RemoveExtension( createData.headerName );

            //    changeFile.AddDictionary( "$(ClassName)", createData.className );
            //    changeFile.AddDictionary( "$(ProjectName)", VCProjcet.Name );
            //    changeFile.AddDictionary( "$(ProjectNameUP)", VCProjcet.Name.ToUpper() );
            //    changeFile.AddDictionary( "$(FileName)", fileName );
            //    changeFile.AddDictionary( "$(FileNameUP)", fileName.ToUpper() );

            //    if( selectItem.ProjectItem != null && selectItem.ProjectItem.Kind == "{6BB5F8F0-4483-11D3-8BCF-00C04F8EC28C}" )
            //    {
            //        VCFilter filter = selectItem.ProjectItem.Object as VCFilter;
            //        foreach( String itemPath in itemList )
            //        {
            //            changeFile.StartChange( itemPath, createData );
            //            filter.AddFile( itemPath );
            //        }
            //    }
            //    else
            //    {
            //        foreach( String itemPath in itemList )
            //        {
            //            changeFile.StartChange( itemPath, createData );
            //            selectItem.Project.ProjectItems.AddFromFile( itemPath );
            //        }
            //    }
            //    VCProjcet.Save();
            //}
            //catch( System.Exception ex )
            //{
            //    MessageBox.Show( "ERROR: " + ex.Message );
            //}
			return true;
		}

	}
}
